home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue68 / Alfresco / Project1.dpr < prev    next >
Encoding:
Text File  |  2001-03-05  |  1.3 KB  |  62 lines

  1. program Project1;
  2.  
  3. {$apptype console}
  4.  
  5. uses
  6.   SysUtils,
  7.   AARegex in 'AARegex.pas';
  8.  
  9. var
  10.   P : TaaRegexParser;
  11.   RC : TaaRegexCompiler;
  12.   i : integer;
  13.   S : string;
  14.   F : text;
  15.   ec : TaaRegexError;
  16. begin
  17.   (*
  18.   S := '(a*[a-z]+)|g?[(ab';
  19.   P := TaaRegexParser.Create(S);
  20.   if not P.Parse(i) then begin
  21.     writeln('error found at ', i);
  22.     writeln(S);
  23.     for i := 1 to length(S) do
  24.       write(i mod 10);
  25.     writeln;
  26.   end;
  27.   P.Free;
  28.   readln;
  29.   *)
  30. //  S := '([a-zA-Z]+\^)|([A-Za-z]+\.[A-Za-z])';
  31. //  S := '.*(true|false);[ ]*$';
  32. //  S := '^ *(function|procedure) +[^.]*$';
  33. //  S := 'if.*then( *| begin *)$';
  34. //  S := 'while.*do( *| begin *)$';
  35. //  S := '^[^ A-Z]*$';
  36. //  S := '^( *|.*:= *)rcSetState';
  37.   S := '\{(.+)+\}'; 
  38. //  S := '\{.+\}';
  39.   RC := TaaRegexCompiler.Create(S);
  40.   if not RC.Parse(i, ec) then begin
  41.     writeln('error found at ', i);
  42.     writeln(S);
  43.     for i := 1 to length(S) do
  44.       write(i mod 10);
  45.     writeln;
  46.   end
  47.   else begin
  48.     RC.IgnoreCase := true;
  49.     System.Assign(F, 'AARegEx.pas');
  50.     System.Reset(F);
  51.     while not eof(F) do begin
  52.       readln(F, S);
  53.       i := RC.MatchString(S);
  54.       if (i <> 0) then
  55.         writeln(i:2, ' ', S);
  56.     end;
  57.     System.Close(F);
  58.   end;
  59.   RC.Free;
  60.   readln;
  61. end.
  62.